package com.lfy.ai;

import cn.hutool.extra.spring.SpringUtil;

import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * 模型分组管理器
 *
 * @author <a href="https://www.lvfeiy.top">lvfeiyang</a>
 * @date 2024/6/25 18:39
 */
public class AiGroupManager {
    private static Map<Integer,AiGroupNorm> aiGroupMap;
    static {
        Map<String, AiGroupNorm> beansOfType = SpringUtil.getBeansOfType(AiGroupNorm.class);
        if (beansOfType!= null && beansOfType.size() > 0) {
            aiGroupMap = beansOfType.values().stream().collect(
                    Collectors.toMap(AiGroupNorm::getModelId, Function.identity()));
        }
    }

    public static AiGroupNorm getAiGroup(Integer modelId) {
        if (aiGroupMap == null) {
            return null;
        }
        return aiGroupMap.get(modelId);
    }

}
